package com.soilflow.web.controller.dahu;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.soilflow.common.domain.DahuCarpooling;
import com.soilflow.info.service.IDahuCarpoolingService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.soilflow.common.annotation.Log;
import com.soilflow.common.core.controller.BaseController;
import com.soilflow.common.core.domain.AjaxResult;
import com.soilflow.common.enums.BusinessType;
import com.soilflow.common.utils.poi.ExcelUtil;
import com.soilflow.common.core.page.TableDataInfo;

/**
 * 车主信息 Controller
 * 
 * @author party
 * @date 2023-10-30
 */
@RestController
@RequestMapping("/system/carpooling")
public class DahuCarpoolingController extends BaseController {
    @Autowired
    private IDahuCarpoolingService dahuCarpoolingService;

    /**
     * 查询车主信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:carpooling:list')")
    @GetMapping("/list")
    public TableDataInfo list(DahuCarpooling dahuCarpooling)
    {
        startPage();
        List<DahuCarpooling> list = dahuCarpoolingService.selectDahuCarpoolingList(dahuCarpooling);
        return getDataTable(list);
    }

    /**
     * 导出【请填写功能名称】列表
     */
    @PreAuthorize("@ss.hasPermi('system:carpooling:export')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DahuCarpooling dahuCarpooling)
    {
        List<DahuCarpooling> list = dahuCarpoolingService.selectDahuCarpoolingList(dahuCarpooling);
        ExcelUtil<DahuCarpooling> util = new ExcelUtil<DahuCarpooling>(DahuCarpooling.class);
        util.exportExcel(response, list, "【请填写功能名称】数据");
    }

    /**
     * 获取车主详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:carpooling:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(dahuCarpoolingService.selectDahuCarpoolingById(id));
    }

    /**
     * 新增车主
     */
    @PreAuthorize("@ss.hasPermi('system:carpooling:add')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DahuCarpooling dahuCarpooling)
    {
        return toAjax(dahuCarpoolingService.insertDahuCarpooling(dahuCarpooling));
    }

    /**
     * 修改车主
     */
    @PreAuthorize("@ss.hasPermi('system:carpooling:edit')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DahuCarpooling dahuCarpooling)
    {
        return toAjax(dahuCarpoolingService.updateDahuCarpooling(dahuCarpooling));
    }

    /**
     * 删除车主
     */
    @PreAuthorize("@ss.hasPermi('system:carpooling:remove')")
    @Log(title = "【请填写功能名称】", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(dahuCarpoolingService.deleteDahuCarpoolingByIds(ids));
    }
}
